package com.lmk.t01;

import java.io.*;

public class ReadTest {
    public static void main(String[] args) {
        String  path="D:/11/1.txt";
        //1.创建文件对象
        File  file=new File(path);
        //2.定义输入流

        try(InputStream is=new FileInputStream(file);) {


            //3.创建字节数组
            byte[] buffer=new byte[(int) file.length()];
            //4.将文件内容读取到字节数组；
            is.read(buffer);
            //5.通过字节数组构建文本字符串
            String content=new String(buffer);
            System.out.println(content);
        } catch (Exception e) {
           e.printStackTrace();
        }

    }
}
